angular.module('meMoreCooperateControllers', ['ionic'])

  .controller('meMoreCooperateCtrl', function ($scope,$state,Storage,MoreCooperate,Toast,ENV) {

    $scope.ENV = ENV;

    //加载联系方式数据
    //$scope.$on('$ionicView.beforeEnter', function () {
      MoreCooperate.getAboutCooperation();
    //});


    $scope.$on('Me.getAboutCooperation', function () {
      var result = MoreCooperate.getAboutCooperationJson();
      $scope.auImgUrl = result.auImgUrl;
      $scope.auWebUrl = result.auWebUrl;
      $scope.contactList = result.contactList;
    });
    $scope.gotoWeb=function(){
      var browser = cordova.ThemeableBrowser.open($scope.auWebUrl, '_system', {
        statusbar: {
          color: '#ffffffff'
        },
        toolbar: {
          height: 44,
          color: '#970b34'
        },
        title: {
          color: '#ffffff',
          staticText: '富隆官网',
          showPageTitle: true
        },
        backButton: {
          wwwImage: 'img/back-btn.png',
          wwwImagePressed: 'img/back-btn.png',
          wwwImageDensity: 2,
          align: 'left',
          event: 'backPressed'
        },
        backButtonCanClose: true
      });

      browser.addEventListener('backPressed', function (e) {
        //alert("点击后退");
        browser.close();
      });
    };

    $scope.phoneCall = function (phoneNum) {
      if(phoneNum!=undefined&&phoneNum!=''){
        if(ionic.Platform.isAndroid()){
          document.location.href = "tel:"+phoneNum;
        }else if(ionic.Platform.isIOS()){
          phonedialer.dial(phoneNum,function(err) {
            if (err == "feature")
            if (err == "empty")
              Toast.showMessage("未知的电话号码");
          });
        }
      }else{
        Toast.showMessage("号码不存在");
      }
    }
  });
